package edu.jsnu.purchase.ticket.controller.ticket;

import constants.FilmType;
import edu.jsnu.purchase.ticket.controller.common.AbstractController;
import edu.jsnu.purchase.ticket.service.FilmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/ticket/index")
public class IndexController extends AbstractController {

    @Autowired
    private FilmService filmService;

    @RequestMapping("index.page")
    public String index(Model model){
        //获取所有影片类型
        List<String> types = FilmType.types;
        model.addAttribute("types", types);
        //获取时间范围
        List<String> years = FilmType.years;
        model.addAttribute("years", years);
        //获取电影总数量
        Integer totalCount = filmService.getTotalCount();
        model.addAttribute("totalCount", totalCount);
        return "ticket/index";
    }
}
